<div id="wrapper">
	<!--左侧导航开始-->
	<?=\app\widgets\MenuWidget::widget();?>
	<!--左侧导航结束-->
	<!--右侧部分开始-->
	<div id="page-wrapper" class="gray-bg dashbard-1">
		<?=$this->render('@app/modules/admin/views/layouts/inc_naver');?>
		<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>工具管理<small>GM工具</small></h5>
					</div>
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="commentForm">
							<div class="form-group">
								<label class="col-sm-3 control-label" for="group_id">服务器：</label>
								<div class="col-sm-8">
									<?php foreach ($serverList as $key => $val):?>
										<input type="radio" name="serverId" value="<?php echo $key ;?>" style="width:15px;">
									<?php echo $val ;?>&nbsp;&nbsp;&nbsp;&nbsp;
									<?php endforeach;?>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">角色ID：</label>
								<div class="col-sm-3">
									<input id="role_id" type="text" class="form-control" name="role_id" value="" required="true" aria-required="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label" for="group_id">道具：</label>
								<div class="col-sm-8">
									<?php foreach ($propList as $key => $val):?>
										<input type="radio" name="propId" value="<?php echo $key ;?>" style="width:15px;">
									<?php echo $val ;?>&nbsp;&nbsp;&nbsp;&nbsp;
									<?php endforeach;?>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">数量：</label>
								<div class="col-sm-3">
									<input id="count" type="text" class="form-control" name="count" value="" required="" aria-required="true">
								</div>
							</div>
							
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-3">
									<button id="submit" class="btn btn-primary" type="button">提交</button>
									<a class="btn btn-white" href="/admin/admin/index">取消</a>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		</div>
	</div>
	<!--右侧部分结束-->
</div>
<script src="/static/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/js/plugins/peity/jquery.peity.min.js"></script>
<script src="/static/js/plugins/iCheck/icheck.min.js"></script>
<script>
		var csrfToken = $('meta[name="csrf-token"]').attr("content");
        $(function(){

        	$('body').on('click', '#submit', function() {
                
                var serverId = $('input:radio[name="serverId"]:checked').val();
                var propId = $('input:radio[name="propId"]:checked').val();
                var roleId = $("#role_id").val();
                var count = $("#count").val();
                var msg = '';
                
                if (serverId == '' || typeof(serverId) == 'undefined' ) {
                	msg += "请选择服务器\n";
                }
                if (roleId == '' ) {
                	msg += "请填写账号\n";
                }
                if (propId == '' || typeof(propId) == 'undefined' ) {
                	msg += "请选择道具\n";
                }
                if (count == '' ) {
                	msg += "请填写数量\n";
                }
                if (msg != '') {
                	return
                }

                $.ajax({
                    type: 'post',
                    url: '/admin/tool/gm',
                    data: {'serverId':serverId, 'propId':propId, 'count':count,'roleId':roleId, _csrf:csrfToken},
                    dataType: 'json',
                    success: function(res) {
                    	alert(res.msg)
                    	if(res.status == true) {
                    		window.location.reload();
                    	}                        
                    }
                });
            });
        });
</script>
